package com.bruce.apkinstaller.install;

/**
 * Created by Administrator on 2018/1/17.
 */

public class FactoryProducer {

    /**
     * 获取指定操作类型的工厂对象
     *
     * @param choice true:安装
     *               false:卸载
     * @return
     */
    public static AbstractFactory getFactory(boolean choice) {
        if (getType(choice).equalsIgnoreCase(ConstantInstallType.INSTALL)) {
            return new FactoryInstall();
        } else if (getType(choice).equalsIgnoreCase(ConstantInstallType.UNINSTALL)) {
            return new FactoryUninstall();
        }
        return null;
    }

    protected static String getType(boolean tag) {
        if (tag) {
            return ConstantInstallType.INSTALL;
        } else {
            return ConstantInstallType.UNINSTALL;
        }
    }
}
